package cn.com.paycn.ken.taglib;

import java.io.IOException;

import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import cn.com.paycn.ken.hbm.Member;
import cn.com.paycn.ken.utils.ResourceUtils;

public class CurrentUsernameTag extends TagSupport {

	public CurrentUsernameTag() {
	}

	public int doStartTag() throws JspException {
		HttpSession session = this.pageContext.getSession();
		Member member = ResourceUtils.currentMember(session);
		if (member != null)
			try {
				this.pageContext.getOut().write(member.getUsername());
			} catch (IOException e) {
				throw new JspException(e);
			}
		return 0;
	}

	private static final long serialVersionUID = 7410179085922234079L;
}